var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var r in t) t.hasOwnProperty(r) && (e[r] = t[r]);
    })(e, t);
}, function(e, t) {
    function r() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (r.prototype = t.prototype, 
    new r());
}), a = this && this.__decorate || function(e, t, r, n) {
    var a, o = arguments.length, c = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, r) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) c = Reflect.decorate(e, t, r, n); else for (var i = e.length - 1; 0 <= i; i--) (a = e[i]) && (c = (o < 3 ? a(c) : 3 < o ? a(t, r, c) : a(t, r)) || c);
    return 3 < o && c && Object.defineProperty(t, r, c), c;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("LoadManager"), s = e("WebManager"), c = cc._decorator, l = c.ccclass, d = c.property, u = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.selfBanner = null, e.currNavigateApp = {
            appid: "",
            name: "",
            is_open_code: !1,
            path: "",
            icon: "",
            qr_code: ""
        }, e;
    }
    return i(e, t), e.prototype.start = function() {
        this.node.y = -cc.winSize.height / 2;
    }, e.prototype.showSelfBanner = function() {
        this.loadSelfBanner(this.selfBanner);
    }, e.prototype.loadSelfBanner = function(t) {
        var n = this;
        (t = void 0 === t ? this.selfBanner : t) && s.default.getInstance().redirect({
            Type: 911,
            CurrentAppid: this.currNavigateApp.appid,
            CurrentPath: this.currNavigateApp.path,
            success: function(e) {
                0 == e.data.code && t && (n.currNavigateApp = e.data.data, n.currNavigateApp && n.currNavigateApp.icon && r.default.getInstance().load({
                    url: n.currNavigateApp.icon,
                    success: function(e) {
                        try {
                            e instanceof cc.Texture2D && (t.spriteFrame = new cc.SpriteFrame(e));
                        } catch (e) {}
                    },
                    fail: function(e) {
                        cc.error(e);
                    }
                }));
            }
        });
    }, e.prototype.bindSelfBanner = function(e) {
        var t = this;
        (e = void 0 === e ? this.selfBanner : e).node.on(cc.Node.EventType.TOUCH_END, function() {
            GA.PA.navigateToMiniProgram({
                pkgName: t.currNavigateApp.appid,
                appId: t.currNavigateApp.appid,
                path: t.currNavigateApp.path,
                success: function() {
                    GA.saveRedirect(911, t.currNavigateApp.appid, t.currNavigateApp.path), t.loadSelfBanner(e);
                },
                fail: function() {
                    t.loadSelfBanner(e);
                }
            });
        });
    }, a([ d(cc.Sprite) ], e.prototype, "selfBanner", void 0), a([ l ], e);
}(cc.Component);

n.default = u;